package com.example.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.example.dao.SysUserRepository;
import com.example.entity.SysUser;

@Service
public class SysUserService implements UserDetailsService{

    @Autowired
    SysUserRepository sysUserRepository;

    @Override
    public UserDetails loadUserByUsername(String name)
            throws UsernameNotFoundException {
        SysUser sysUser=sysUserRepository.findByUsername(name);
        if(sysUser==null){
            throw new UsernameNotFoundException("该用户不存在！");
        }
        return sysUser;
    }
}
